#include <iostream>

using namespace std;

const int N = 1e4 + 10;
int n, m, w;
int c[N], d[N];
int un_c[N], un_d[N], pos;
int f[N];
int fa[N];

int find(int x)
{
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void un(int x, int y)
{
	fa[find(x)] = find(y);
}

int main()
{
	cin >> n >> m >> w;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> c[i] >> d[i];
	}
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i <= m; i++)
	{
		int x, y; cin >> x >> y;
		un(x, y);
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(fa[i] == i)
		{
			pos++;
			for(int j = 1; j <= n; j++)
			{
				if(find(j) != i) continue;
				un_c[pos] += c[j]; un_d[pos] += d[j];
			}
		}
	}
//	cout << pos << endl;
	// 01beibao
	for(int i = 1; i <= pos; i++)
		for(int j = w; j >= un_c[i]; j--)
			f[j] = max(f[j], f[j - un_c[i]] + un_d[i]);
	cout << f[w] << endl;
	return 0;
}
